//
//  Order.swift
//  ECApp
//
//  Created by ping Cheng on 2017/10/27.
//

import Foundation
import PerfectLib

enum OrderStatus:Int {
    case none = -1
    case notPaid = 1
    case paied
    case salesReturn
}
enum OrderItemStatus:Int {
    case normal = 1
    case applySalesReturn
    case salesReturnSuccess
}

class Order: JSONConvertibleObject {
    var id = -1
    var orderNo = ""
    var amount:Float = 0
    var currency = ""
    var status = OrderStatus.none
    var items = [OrderItem]()
    
    override func getJSONValues() -> [String : Any] {
        return [ "id":id,
                 "orderNo":orderNo,
                 "amount":amount,
                 "currency":currency,
                 "status":status.rawValue,
                 "products":items
        ]
    }
}

class OrderItem: JSONConvertibleObject {
    var id = -1
    var name = ""
    var price :Float = 0
    var properties = ""
    var thumbnailUrl = ""
    var quantity = 0
    var status = OrderItemStatus.normal
    
    override func getJSONValues() -> [String : Any] {
        return [ "id":id,
                 "itemName":name,
                 "price":price,
                 "properties":properties,
                 "thumbnailUrl":thumbnailUrl,
                 "quantity":quantity,
                 "status":status.rawValue
        ]
    }
}
